package com.example.tsproject.mapper;

import com.example.tsproject.entity.Students;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Optional;

/**
* @author DELL
* @description 针对表【students】的数据库操作Mapper
* @createDate 2024-09-24 21:13:24
* @Entity com.example.tsproject.entity.Students
*/
@Mapper
public interface StudentsMapper extends BaseMapper<Students> {
    @Select("SELECT * FROM students WHERE student_number=#{student_number} AND password=#{password}")
    Optional<Students> findStudentsJudge(@Param("student_number") String student_number, @Param("password") String password);

    @Select("SELECT * FROM students WHERE student_number=#{student_number}")
    Students findStudents(@Param("student_number") String student_number);

    List<Students> findAllStudents(String name, String id, String stuClass);

    @Delete("UPDATE Students\n" +
            "SET status = 'inactive'\n" +
            "WHERE id = #{id};")
    void delete(String id);

    @Insert("INSERT INTO Students (student_number, password, name, stuclass, email, avatar, status) " +
            "VALUES (#{studentNumber}, #{password}, #{name}, #{stuclass}, #{email}, 1, 'active')")
    void add(String studentNumber, String name, String password, String stuclass, String email);
}




